const HtmlWebpackPlugin = require('html-webpack-plugin')
const path = require('path')
module.exports = {
    mode: 'development',
    entry: './app.js',
    output: {
        publicPath: '/',
        clean: true,
    },
    devServer: {
        // static: {
        //     directory:path.resolve(__dirname,'./dist'),
        // },// 默认是把/dist目录当作web服务的根目录
        static: path.resolve(__dirname,'./dist'),
        compress: false,//可选择开启gzips压缩功能，对应静态资源请求的响应头里的--Content-Encoding: gzip,
        port: 3000, // 端口号
        headers: {
            'X-Access-Token': 'hrw'
        },
        proxy: [{
            '/api': {
                target:'http://localhosh:9000',
                // changeOrigin:true,
                // pathRewrite: {  
                //     '^/api': '' // 路径重写，移除路径中的/api  
                //   }  
            }
        }],
        historyApiFallback: true,
        hot: true,//热替换
        liveReload: false, //默认为true，即开启热更新功能。
    },
    // 浏览器代码提示配置(debug功能)----source-map
    devtool: 'eval',
    plugins: [
        new HtmlWebpackPlugin()
    ]
}